package database;

import java.util.List;

import toDo.app.models.ToDoListItem;
import toDo.app.models.User;
import android.content.Context;
/**
 *encapsulates the database so as to be friendly
 * @author Sparky
 *
 */
public class DatabaseFacade {
	static final String DATABASE_NAME = "users.db"; //$NON-NLS-1$
	
	private DatabaseFacade(){}
	
	public static User addUser(Context context, User user){
		return (new UserDatabaseConnector(context)).addUser(user);
	}
	
	public static User isValidUser(Context context, User user){
		return (new UserDatabaseConnector(context)).isValidUser(user);
	}
	
	public static void addToDoListItem(Context context, User user, ToDoListItem item){
		(new ListDatabaseConnector(context)).addToDoListItem(user, item);
	}
	
	public static void changeToDoListItem(Context context, User user, ToDoListItem item){
		(new ListDatabaseConnector(context)).changeToDoListItem(user, item);
	}
	
	public static void processToDoListItem(Context context, User user, ToDoListItem item){
		if(item.isNew()){
			(new ListDatabaseConnector(context)).addToDoListItem(user, item);			
		} else {
			(new ListDatabaseConnector(context)).changeToDoListItem(user, item);
		}
	}
	
	public static List<ToDoListItem> getList(Context context, User user){
		return (new ListDatabaseConnector(context)).getList(user);
	}
	
	public static List<ToDoListItem> getListByType(Context context, User user, String type){
		return (new ListDatabaseConnector(context)).getListByType(user, type);
	}
	
	public static List<ToDoListItem> getListByDate(Context context, User user, int date, boolean after){
		return (new ListDatabaseConnector(context)).getListByDate(user, date, after);
	}
	
	public static List<ToDoListItem> getListByCompleted(Context context, User user, boolean completed){
		return (new ListDatabaseConnector(context)).getListByCompleted(user, completed);
	}
	
	public static List<String> getListTypes(Context context, User user){
		return (new ListDatabaseConnector(context)).getTypes(user);
	}
}
